import api from "@/api/request.js" //先导入封装好的

const getBanner = async () => { //轮播图
	let data = await api({
		url: 'index/getBanner'
	})
	return data
}

const getCateToGame = async () => { //分类首页
	let data = await api({
		url: 'index/getCateToGame'
	})
	return data
}


const getGameNew = async () => { // 最新游戏
	let data = await api({
		url: "index/getGameNew"
	})
	return data
}
const getRank = async (page,limit,cate) => { //游戏排行
	let data = await api({
		url: 'index/getRank',
		data:{
			page:page,
			limit:limit,
			cate:cate
		}
	})
	return data
}

const getSearchList = async (page,limit,keyword) => { //搜索游戏
	let data = await api({
		url: 'index/getSearchList',
		data:{
			page:page,
			limit:limit,
			keyword:keyword
		}
	})
	return data
}

const getCate = async (val) => { //获取分类列表
	let data = await api({
		url: 'index/getCateList',
		data:{
			type:val
		}
	})
	return data
}
const getGameListById = async (val) => { //根据分类获取游戏列表
	let data = await api({
		url: 'index/getGameListById',
		data:{
			cate_id:val
		}
	})
	return data
}
const getGameListByCateId = async (page,limit,cate) => { //分类详情页游戏
	let data = await api({
		url: 'index/getGameListByCateId',
		data:{
			page:page,
			limit:limit,
			cate_id:cate
		}
	})
	return data
}

const sendMsg = async (phone) => { //发送短信
	let data = await api({
		url: 'index/sendMsg',
		data:{
			phone:phone,
		}
	})
	return data
}

const subIdcard = async (name,code,phone) => { //发送实名认证
	let data = await api({
		url: 'index/subIdcard',
		method:'POST',
		dataType:'json',
		data:{
			name:name,
			code:code,
			phone:phone
		}
	})
	return data
}


const login = async (phone,code) => { //发送短信
	let data = await api({
		url: 'index/login',
		data:{
			phone:phone,
			code:code
		}
	})
	return data
}

const editUser = async (uid,avatar,userName) => { //发送短信
	let data = await api({
		url: 'index/editUser',
		data:{
			uid:uid,
			avatar:avatar,
			userName:userName
		}
	})
	return data
}

const getMsgList = async () => { //获取消息列表
	let data = await api({
		url: 'index/getMsgList'
	})
	return data
}


const getAnnouncement = async () => { //获取公告
	let data = await api({
		url: 'index/getAnnouncement'
	})
	return data
}

// export const floor = async () => { //楼层   这是一种导出方式
// 	let data = await api({
// 		url: 'home/floordata'
// 	})
// 	return data
// }
export {							//这是另一种导出方式
	getBanner,
	getGameNew,
	getRank,
	getCate,
	getGameListById,
	getCateToGame,
	getGameListByCateId,
	getSearchList,
	sendMsg,
	login,
	editUser,
	getMsgList,
	subIdcard,
	getAnnouncement
}

